<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/tag/localeTag.tld" prefix="t"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; UTF-8">
<title>Q & A </title>
<link rel="shortcut icon" href="resources/images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="resources/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="resources/css/style.css" />
<script type="text/javascript" src="resources/js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="resources/js/bootstrap.js"></script>
<script type="text/javascript" src="resources/js/qanda.js"></script>
<!-- <script type="text/javascript" src="resources/js/getUserId.js"></script> -->
</head>
<body>
	<jsp:include page="parts/header.jsp"></jsp:include>
	<jsp:include page="parts/navigation.jsp"></jsp:include>
	<div class="content">
		<jsp:include page="parts/leftmenu.jsp"></jsp:include>
		<div class="page">
			<h2>
				<t:locale mName="admin.title" />
			</h2>
			<c:choose>
				<c:when test="${not empty users}">
					<table class="table table-striped table-condensed text-center">
						<thead>
							<tr>
								<th class="text-center"><a href="sortRole"><t:locale mName="admin.role" /></a></th>
								<th class="text-center"><a href="sfName"><t:locale mName="admin.firstName" /></a></th>
								<th class="text-center"><a href="slName"><t:locale mName="admin.lastName" /></a></th>
								<th class="text-center"><a href="sLogin"><t:locale mName="admin.login" /></a></th>
								<th class="text-center"><a href="sEmail"><t:locale mName="admin.email" /></a></th>
								<th class="text-center"><t:locale mName="admin.confirm" /></th>
								<th class="text-center"><t:locale mName="admin.status" /></th>
								<th class="text-center"><t:locale mName="admin.appointing" /></th>
							</tr>
						</thead>
						<c:forEach var="u" items="${users}">
							<tr>
								<td><c:forEach var="r" items="${roles}">
										<c:if test="${u.roleId==r.id}">${r.name}</c:if>
									</c:forEach></td>
								<td>${u.fName}</td>
								<td>${u.lName}</td>
								<td>${u.login}</td>
								<td>${u.email}</td>
								<td class="text-center"><c:if test="${u.confirmationStatus==true}">
										<span class="glyphicon glyphicon-ok"></span>
									</c:if> <c:if test="${u.confirmationStatus==false}">
										<span class="glyphicon glyphicon-minus"></span>
									</c:if></td>
								<td class="text-center"><c:if test="${u.status==true}">
										<c:if test="${u.dateBanOff != null}">
											<p>${u.dateBanOff}
										</c:if>
										<c:if test="${u.dateBanOff == null}">
											<p>Permanent
										</c:if>
									</c:if> <c:if test="${u.status==false}">
										<span class="glyphicon glyphicon-minus"></span>
									</c:if></td>
								<td>
									<form action="appointing" method="POST">
										<c:choose>
											<c:when test="${u.roleId==3}">
												<input type="button" class="btn btn-info btn-sm btn-block" value="<t:locale mName="admin.appointingModerator"/>" onclick="showModeratorCategory(${u.id})">
											</c:when>
											<c:when test="${u.roleId==2}">
												<button type="submit" class="btn btn-danger btn-sm btn-block" name="appoint" value="${u.id}">
													<t:locale mName="admin.appointingUser" />
												</button>
											</c:when>
										</c:choose>
									</form>
								</td>
							</tr>
						</c:forEach>
					</table>
				</c:when>
			</c:choose>
			<form action="selCategory" method="POST" class="form-horizontal">
				<div id="selectModeratorCategory">
					<input type="hidden" name="uID" id="uID">
					<div class="form-group">
						<div class="col-xs-6">
							<h2>
								<t:locale mName="admin.chooseCategories" />
							</h2>
						</div>
						<div class="col-xs-6 text-right">
							<span onclick="selectModeratorCategoryClose()" class="glyphicon glyphicon-remove"></span>
						</div>
					</div>
					<div id="content-selectModeratorCategory">
						<div class="form-group">
							<div class="col-xs-12">
								<c:forEach items="${categories}" var="categ">
									<div class="btn-block">
										<div class="btn-group" data-toggle="buttons">
											<label class="btn btn-success">
												<input type="checkbox" name="addCategory" value="${categ.id}">
												<span class="glyphicon glyphicon-plus"></span>
												${categ.name}
											</label>
										</div>
									</div>
								</c:forEach>
							</div>
						</div>
					</div>
					<div class="form-group">
						<div class="col-xs-12">
							<input type="submit" class="btn btn-info btn-lg" value="<t:locale mName="admin.ok"/>">
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
	<jsp:include page="parts/footer.jsp"></jsp:include>
</body>
</html>